# consumers.py
from channels.generic.websocket import AsyncWebsocketConsumer

class StockConsumer(AsyncWebsocketConsumer):
    async def connect(self):
        await self.accept()
        print("已连接")

    async def disconnect(self, close_code):
        print("已断开")

    async def receive(self, text_data):
        # 处理接收到的消息
        print("接收到消息：", text_data)

    async def send_stock_price(self, event):
        # 发送股票报价数据给客户端
        self.send("abc")
